﻿using System.Collections.Generic;
using System.Linq;
using Creventive.Wpf.ShellFactory.Modules;
using Creventive.Wpf.ShellFactory.Services;

namespace $rootnamespace$
{
    /// <summary>
    /// A controller for the $safeitemname$ extension.
    /// </summary>
    public class $safeitemname$
    {
        private HashSet<$saferootitemname$> extensions = new HashSet<$saferootitemname$>();

        /// <summary>
        /// Initializes a new instance of the <see cref="$safeitemname$"/> class.
        /// </summary>
        public $safeitemname$()
        {
            IApplicationModuleService applicationModuleService = ServiceContainer.Default.EnsureService<IApplicationModuleService>();
            foreach (var module in applicationModuleService.ApplicationModules)
            {
                var extension = $saferootitemname$.GetExtension(module);
                if (extension != null)
                {
                    this.extensions.Add(extension);
                    // TODO: Add any event handlers etc.
                }
            }
            this.Reset();
        }

        // TODO: Add properties and methods which reflects a joining of all $saferootitemname$ extensions

        /// <summary>
        /// Resets the controller.
        /// </summary>
        public void Reset()
        {
            // TODO: Force a reload of all extension properties
        }
    }
}